package com.xja.service.impl;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xja.mapper.QuestionMapper;
import com.xja.model.entity.Question;
import com.xja.service.IQuestionService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 问题表--用于体质评估 服务实现类
 * </p>
 *
 * @author tanggy
 * @since 2025-06-11
 */
@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements IQuestionService {

    @Override
    public Page<Question> search(String keyword, Long pageNum, Long pageSize) {
        // 1.设置分页参数
        Page<Question> p = Page.of(pageNum, pageSize);
        // 2.设置查询条件
        LambdaQueryWrapper<Question> wrapper = this.lambdaQuery()
                .getWrapper()
                .like(StrUtil.isNotBlank(keyword), Question::getContent, keyword);
        // 3.执行查询
        this.page(p, wrapper);
        // 4.返回分页结果
        return p;
    }
}
